package com.ruoyi.swla2.service.impl;

import java.util.Arrays;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.swla2.mapper.VideoSpectrumMapper;
import com.ruoyi.swla2.domain.VideoSpectrum;
import com.ruoyi.swla2.service.IVideoSpectrumService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
/**
 * 音频文件频谱图Service业务层处理
 *
 * @author gdqt
 * @date 2025-06-26
 */
@Service
public class VideoSpectrumServiceImpl extends ServiceImpl<VideoSpectrumMapper, VideoSpectrum> implements IVideoSpectrumService
{
    @Autowired
    private VideoSpectrumMapper videoSpectrumMapper;

    /**
     * 查询音频文件频谱图
     *
     * @param id 音频文件频谱图主键
     * @return 音频文件频谱图
     */
    @Override
    public VideoSpectrum selectVideoSpectrumById(Long id)
    {

        return videoSpectrumMapper.selectById(id);
    }

    /**
     * 查询音频文件频谱图列表
     *
     * @param videoSpectrum 音频文件频谱图
     * @return 音频文件频谱图
     */
    @Override
    public List<VideoSpectrum> selectVideoSpectrumList(VideoSpectrum videoSpectrum)
    {
        LambdaQueryWrapper<VideoSpectrum> queryWrapper = new LambdaQueryWrapper<>();
        if(videoSpectrum.getFileVideoId() != null){
            queryWrapper.eq(VideoSpectrum::getFileVideoId,videoSpectrum.getFileVideoId());
        }
        if(videoSpectrum.getDetailData() != null){
            queryWrapper.eq(VideoSpectrum::getDetailData, videoSpectrum.getDetailData());
        }
        return videoSpectrumMapper.selectList(queryWrapper);
    }

    /**
     * 新增音频文件频谱图
     *
     * @param videoSpectrum 音频文件频谱图
     * @return 结果
     */
    @Override
    public int insertVideoSpectrum(VideoSpectrum videoSpectrum)
    {
        return videoSpectrumMapper.insert(videoSpectrum);
    }

    /**
     * 修改音频文件频谱图
     *
     * @param videoSpectrum 音频文件频谱图
     * @return 结果
     */
    @Override
    public int updateVideoSpectrum(VideoSpectrum videoSpectrum)
    {
        videoSpectrum.setUpdateTime(DateUtils.getNowDate());
        return videoSpectrumMapper.updateById(videoSpectrum);
    }

    /**
     * 批量删除音频文件频谱图
     *
     * @param ids 需要删除的音频文件频谱图主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteVideoSpectrumByIds(Long[] ids)
    {
        return videoSpectrumMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除音频文件频谱图信息
     *
     * @param id 音频文件频谱图主键
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteVideoSpectrumById(Long id)
    {
        return videoSpectrumMapper.deleteById(id);
    }
}
